define(['app'], function(app) {
    'use strict';
    //实例化方法
    var factory = function (Http) {
        /**
         * 一键切换数据获取方式
         * @param {Object} result
         */
        function get_data_getsearchlist(result) {
            if (false) {
                result = '{"success": true,"msg": "","result": {"store_count": "500","data": [{"goods_id": 1,"name": "十字螺丝刀","introduce": "十字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "./img/upload/pro-img01.jpg","storenumber": 100,"salenumber": 20,"personlimit": 3,"qq": "1234567","phone": "18912345678"},{"goods_id": 2,"name": "一字螺丝刀","introduce": "一字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "./img/upload/pro-img01.jpg","storenumber": 80,"salenumber": 10,"personlimit": 3,"qq": "1234567","phone": "18912345678"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            }
            else {
                return result;
            }
        }
      
        //返回信息
        return {
            //商品排序
            getlist: function (cat_type, orderby, key,store_cat,pagelimit,nPage,callback,calldone) {
                Http.post({
                    method: 'goods.search.getlist',
                    cat_type:cat_type,
                    orderby:orderby,
                    key:key,
                    store_cat:store_cat,
                    pagelimit:pagelimit,
					nPage:nPage
                }, function (result) {
                    //请求成功
                    if (callback) {
                        callback(get_data_getsearchlist(result).result);
                    }
                }, function (e) {
                    //请求异常
                }, function () {
                    //请求完成，一般不做什么事情
                    if(calldone)
						calldone();
                });
            }
            
            
        }
    }
    factory.$inject = ['Http'];
    return app.registerService("Proconsult", factory);
});